<?php
namespace Home\Controller;


use Common\Controller\HomeController;

class IndexController extends HomeController
{
    /**
     * 首页展示
     * @author Mr.Alien
     * @return string
     */
    public function index()
    {
        $this->display();
    }

    /**
     * 顶部菜单
     * @author Mr.Alien
     * @return string
     */
    public function top()
    {   
        $notice = M('Notice')->where(array('id'=>1))->getField('content');
        $this->assign('notice',$notice);
        $this->display();
    }

    /**
     * 首页左侧
     * @author Mr.Alien
     * @return string
     */
    public function left()
    {
        $this->display();
    }

    public function test()
    {
        $container_list = M('Container')->select();
        foreach ($container_list as $key => $value) {
            $used = M("Take")->where(array('status'=>1,'user_id'=>$value['user_id'],'container_id'=>$value['id']))->count();
            M('Container')->where(array('id'=>$value['id']))->save(array('used'=>$used));
        }
    }

    public function sms()
    {
        $container_list = M('Container')->select();
        foreach ($container_list as $key => $value) {
           $num = M('Take')->where(array('container_id'=>$value['id'],'status'=>1))->count();
           M('Container')->where(array('id'=>$value['id']))->save(array('used'=>$num));
        }
        echo 'ok';
    }
}